package lily.phs.object;
import lily.phs.database.Constants;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
public class PersonInfoLog implements Constants {
	private Context myContext;
	private int pilo_log_id=-1;
	private int pilo_profile_id=-1;
//	private int pilo_person_info_id=-1;
	private String pilo_timestamp="";
	private String pilo_column_value="";
	private String pilo_previous_value="";
	private String pilo_current_value="";
	public PersonInfoLog(Context context){
		this.myContext=context;
	}
	public int getPilo_log_id() {
		return pilo_log_id;
	}

	public void setPilo_log_id(int piloLogId) {
		pilo_log_id = piloLogId;
	}

	public int getPilo_profile_id() {
		return pilo_profile_id;
	}

	public void setPilo_profile_id(int piloProfileId) {
		pilo_profile_id = piloProfileId;
	}

	/*public int getPilo_person_info_id() {
		return pilo_person_info_id;
	}

	public void setPilo_person_info_id(int piloPersonInfoId) {
		pilo_person_info_id = piloPersonInfoId;
	}
*/
	public String getPilo_timestamp() {
		return pilo_timestamp;
	}

	public void setPilo_timestamp(String piloTimestamp) {
		pilo_timestamp = piloTimestamp;
	}

	public String getPilo_column_value() {
		return pilo_column_value;
	}

	public void setPilo_column_value(String piloColumnValue) {
		pilo_column_value = piloColumnValue;
	}

	public String getPilo_previous_value() {
		return pilo_previous_value;
	}

	public void setPilo_previous_value(String piloPreviousValue) {
		pilo_previous_value = piloPreviousValue;
	}

	public String getPilo_current_value() {
		return pilo_current_value;
	}

	public void setPilo_current_value(String piloCurrentValue) {
		pilo_current_value = piloCurrentValue;
	}

	public void insertPersonInfoLog(){
		ContentValues value=new ContentValues();
		value.put(PILO_LOG_ID, this.getPilo_log_id());
		value.put(PILO_PROFILE_ID, this.getPilo_profile_id());
	//	value.put(PILO_PERSON_INFO_ID, this.getPilo_person_info_id());
		value.put(PILO_TIMESTAMP, this.getPilo_timestamp());
		value.put(PILO_COLUMN_VALUE, this.getPilo_column_value());
		value.put(PILO_PREVIOUS_VALUE, this.getPilo_previous_value());
		value.put(PILO_CURRENT_VALUE, this.getPilo_current_value());
		myContext.getContentResolver().insert(CONTENT_URI_TB4, value);
	}
	public void selectPersonInfoLog(int pro){
		Cursor cursor=myContext.getContentResolver().query(CONTENT_URI_TB4, null, 
											PILO_PROFILE_ID + "=" + pro +"", null, null);
		System.out.println("cursor.getCount="+cursor.getCount());
		while(cursor.moveToNext()){
			this.pilo_profile_id=cursor.getInt(cursor.getColumnIndex(PILO_PROFILE_ID));
			this.pilo_log_id=cursor.getInt(cursor.getColumnIndex(PILO_LOG_ID));
		//	this.pilo_person_info_id=cursor.getInt(cursor.getColumnIndex(PILO_PERSON_INFO_ID));
			this.pilo_timestamp=cursor.getString(cursor.getColumnIndex(PILO_TIMESTAMP));
			this.pilo_column_value=cursor.getString(cursor.getColumnIndex(PILO_COLUMN_VALUE));
			this.pilo_current_value=cursor.getString(cursor.getColumnIndex(PILO_CURRENT_VALUE));
			this.pilo_previous_value=cursor.getString(cursor.getColumnIndex(PILO_PREVIOUS_VALUE));
			
		}
		cursor.close();
	}
	public void updatePersonInfoLog(int pro){
		ContentValues value=new ContentValues();
		value.put(PILO_LOG_ID, this.pilo_log_id);
	//	value.put(PILO_PERSON_INFO_ID, this.pilo_person_info_id);
		value.put(PILO_TIMESTAMP, this.pilo_timestamp);
		value.put(PILO_COLUMN_VALUE, this.pilo_column_value);
		value.put(PILO_CURRENT_VALUE, this.pilo_current_value);
		value.put(PILO_PREVIOUS_VALUE, this.pilo_previous_value);
		myContext.getContentResolver().update(CONTENT_URI_TB4, value, PILO_PROFILE_ID +"=" + pro + "", null);
	}
	public void deletePersonInfoLog(int pro){
		myContext.getContentResolver().delete(CONTENT_URI_TB4, PILO_PROFILE_ID + "=" + pro + "", null);
	}

}
